/**
 * @program: LeetCode
 * @description: LeetCode :
 * @author: WXY
 * @create: 2023-01-05 16:00
 * @Version 1.0
 **/
public class Num059_fib {
    public static int fib(int n) {
        int[] dp = new int[50];
        dp[0] = 0;
        dp[1] = 1;
        for (int i = 2; i <= n; i++) {
            dp[i] = dp[i - 1] + dp[i - 2];
        }
        return dp[n];
    }

    public static int fib1(int n) {
        if (n == 1 || n == 0) return n;
        return fib1(n - 1) + fib1(n - 2);
    }

    public static void main(String[] args) {
        int max = 20;
        for (int i = 0; i < max; i++) {
            int rand = (int) (Math.random() * 30);
            int fib = fib(rand);
            int fib1 = fib1(rand);
            if (fib1 != fib) {
                System.out.println("BUG BUG BUG");
            }
            System.out.println(fib);
        }
    }
}
